package control

import (
	"service/app/dao"
	"service/app/dto"
)

type AdminContr struct {
	BaseContr
	Dao *dao.AdminDao
}

var AdminC *AdminContr

type EfectList struct {
	Addlist [][]string
	Rmlist  [][]string
}

func NewAdminContr() *AdminContr {
	if AdminC == nil {
		AdminC = &AdminContr{
			Dao: dao.NewAdminDao(),
		}
	}
	return AdminC
}

func (m *AdminContr) AdminRmnotUseLinkC(SysList *dto.SysListAc) error {
	return m.Dao.AdminRmnotUseLinkD(SysList)
}

// func (m *AdminContr) GetList(paginat *dto.ReqPaginat) []mode.CasbinRule {
// 	return m.Dao.AdminGetRole(paginat)
// }

// func (m *AdminContr) RolesByUsernameC(username string) (*[]string, error) {
// 	return m.Dao.RolesByUsernameD(username)
// }

func MatchString(target, sources []string, username string) [][]string {
	var reslist [][]string
	for r := range target {
		tag := false
		targetItem := target[r]
		for i := range sources {
			sourcesItem := sources[i]
			if targetItem == sourcesItem {
				tag = true
			}
		}
		if !tag {
			var temp = []string{username, targetItem}
			reslist = append(reslist, temp)
		}
	}
	return reslist
}
